import logging


class Log:
    def __init__(self):
        self.logger = logging.getLogger('log1')
        self.log_handler = logging.FileHandler(filename="useapi/static/test.log", mode="a")
        self.stream_handler = logging.StreamHandler()

        self.formatter = logging.Formatter("%(asctime)s %(name)s:%(levelname)s:%(message)s")

        self.stream_handler.setFormatter(self.formatter)
        self.log_handler.setFormatter(self.formatter)
        self.log_handler.setLevel(logging.DEBUG)
        self.logger.addHandler(self.log_handler)
        self.logger.addHandler(self.stream_handler)

    def log_info(self, mess):
        self.logger.info(mess)

    def log_warn(self, mess):
        self.logger.warning(mess)
